package com.andy.beef.ui.main.viewmodel

import com.andy.module.base.BasePageListViewModel
import com.andy.module.ext.genLiveData
import com.andy.module.ext.requestAny
import com.andy.module.network.ApiPagerResponse
import com.andy.module.network.ApiResponse
import com.andy.beef.ui.main.api.TradeApiService
import com.andy.beef.ui.main.api.tradeService
import com.andy.beef.ui.main.bean.EnterInfoBean

/**
 * @creator:LuoFan
 * @date:2022/6/6
 * @description:
 */
class EnterInfoListViewModel : BasePageListViewModel<EnterInfoBean>() {

    val deleteRecordResult = genLiveData<Any>()

    override suspend fun genRequest(): ApiResponse<ApiPagerResponse<EnterInfoBean>> {
        return tradeService.getEnterInfoList(TradeApiService.URL_ENTER_INFO_LIST, params)
    }

    fun deleteRecord(bean: EnterInfoBean) {
        val params = HashMap<String, Any>()
        params["entryInfoId"] = bean.id
        requestAny({
            tradeService.postResultAny(TradeApiService.URL_DELETE_ENTER_INFO, params)
        }, deleteRecordResult)
    }
}